<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>playlist_m3u (Playlists)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File playlists.rb, line 28</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">playlist_m3u</span>(<span class="ruby-identifier">opts</span>={})  <span class="ruby-comment cmt">#:doc:</span>
    <span class="ruby-identifier">playlist</span> = <span class="ruby-value str">&quot;#EXTM3U\n\n&quot;</span>;
    <span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">song</span>, <span class="ruby-identifier">mp3</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">song_name</span> = (<span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:format</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">apply_format</span>(<span class="ruby-identifier">song</span>, <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:format</span>]) <span class="ruby-operator">:</span> <span class="ruby-identifier">song</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-ivar">@exts</span>, <span class="ruby-value str">&quot;&quot;</span>);
      <span class="ruby-identifier">time_secs</span> = <span class="ruby-identifier">mp3</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">to_s</span>;
      <span class="ruby-identifier">path</span> = <span class="ruby-identifier">get_path</span>(<span class="ruby-identifier">opts</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">song</span>;
      <span class="ruby-identifier">playlist</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#EXTINF:#{time_secs},#{song_name}\n&quot;</span>
      <span class="ruby-identifier">playlist</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\n\n&quot;</span>;
    <span class="ruby-keyword kw">end</span>
    <span class="ruby-identifier">write_file</span>(<span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:save</span>], <span class="ruby-identifier">playlist</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:save</span>];
    <span class="ruby-identifier">playlist</span>;
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>